#include <iostream>
#include <memory>
class Gpu
{
    public:
        virtual void assemble() = 0;
};

class NvidiaGpu: public Gpu
{
    public:
        virtual void assemble() override
        {
            std::cout << "Manufacturing Nvidia Gpu..."<<std::endl;
        }
};
class IntelGpu: public Gpu
{
    public:
        virtual void assemble() override
        {
            std::cout << "Manufacturing Intel Gpu..."<<std::endl;
        }
};
class Cpu
{
    public:
        virtual void assemble() = 0;
};

class NvidiaCpu: public Cpu
{
    public:
        virtual void assemble() override
        {
            std::cout << "Manufacturing Nvidia Cpu..."<<std::endl;
        }
};
class IntelCpu: public Cpu
{
    public:
        virtual void assemble() override
        {
            std::cout << "Manufacturing Intel Cpu..."<<std::endl;
        }
};
//抽象工厂
class Company{
    public:
        virtual std::shared_ptr<Cpu> createCpu() = 0;
        virtual std::shared_ptr<Gpu> createGpu() = 0;
        //...
};

class NvidiaCompany: public Company
{
    public:
        virtual std::shared_ptr<Cpu> createCpu()
        {
            return std::make_shared<NvidiaCpu>();
        }
        virtual std::shared_ptr<Gpu> createGpu(){
            return std::make_shared<NvidiaGpu>();
        }
};
class IntelCompany: public Company
{
    public:
        virtual std::shared_ptr<Cpu> createCpu()
        {
            return std::make_shared<IntelCpu>();
        }
        virtual std::shared_ptr<Gpu> createGpu(){
            return std::make_shared<IntelGpu>();
        }
};
void produceCpu(std::shared_ptr<Cpu> cpu){
    cpu->assemble();
}
void produceGpu(std::shared_ptr<Gpu> gpu){
    gpu->assemble();
}
int main()
{
    std::shared_ptr<Company> Nvidia = std::make_shared<NvidiaCompany>();
    std::shared_ptr<Company> intel = std::make_shared<IntelCompany>();
    produceCpu(Nvidia->createCpu());
    produceGpu(Nvidia->createGpu());
    produceCpu(intel->createCpu());
    produceGpu(intel->createGpu());
    return 0;
}